package com.zjhn.ds.controller;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.common.PageResult;
import com.zjhn.ds.domain.dto.pc.*;
import com.zjhn.ds.param.GetOperatorPageParam;
import com.zjhn.ds.param.GetSpinnerPageParam;
import com.zjhn.ds.param.GetStationPageParam;
import com.zjhn.ds.service.CommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller
 * @Author: sxt
 * @CreateTime: 2023-09-01  14:57
 * @Description: 通用接口
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/common")
@Api(tags = "通用接口")
public class CommonController {

    @Resource
    private CommonService commonService;

    @ApiOperation("按条件分页查询不是挡车工的员工信息 车间添加挡车工查询接口")
    @PostMapping("/getOperatorsPage")
    public BizResult<PageResult<OperatorDto>> getOperatorsPage(@RequestBody @Valid GetOperatorPageParam param) {
        log.info("====[INFO]=========CommonController====getOperatorsPage param:{}", JSON.toJSONString(param));
        return commonService.getOperatorsPage(param);
    }

    @ApiOperation("按条件分页查询车间未绑定挡车工信息 小组添加挡车工查询接口")
    @PostMapping("/getSpinnerPage")
    public BizResult<PageResult<SpinnerDto>> getSpinnerPage(@RequestBody @Valid GetSpinnerPageParam param) {
        log.info("====[INFO]=========CommonController====getSpinnerPage param:{}", JSON.toJSONString(param));
        return commonService.getSpinnerPage(param);
    }

    @ApiOperation("按条件分页查询车间未绑定工位信息 小组添加工位查询接口")
    @PostMapping("/getStationPage")
    public BizResult<PageResult<WorkShopStationDto>> getStationPage(@RequestBody @Valid GetStationPageParam param) {
        log.info("====[INFO]=========CommonController====getStationPage param:{}", JSON.toJSONString(param));
        return commonService.getStationPage(param);
    }

    @ApiOperation("查询设备类别列表 设备设置类别查询接口")
    @PostMapping("/getTypeList")
    public BizResult<List<EquipmentTypeDto>> getTypeList() {
        log.info("====[INFO]=========CommonController====getTypeList");
        return commonService.getTypeList();
    }

    @ApiOperation("查询模型列表 设备设置模型查询接口")
    @PostMapping("/getModelList")
    public BizResult<List<ModelDto>> getModelList() {
        log.info("====[INFO]=========CommonController====getModelList");
        return commonService.getModelList();
    }

}
